import Request_1 from './Request.js'

import util from '@/static/util.js'
/** 用户模块 */
var SocketUser = (function() {

	function SocketUser() {}




	//常规ajax请求
	SocketUser.prototype.AjaxRequest = function(url, paramster, callback, isload = true, iserrorback = false) {
		if (isload) {
			uni.showLoading({
				title: 'loading...'
			});
		}



		paramster.timestamp=util.getTimeStamp()
		var header={}

		var request = new Request_1.Request('http://quant.colorsofts.com/'+util.RequestUrlFormat(url), paramster);
		request.Then(function(e) {

			if (isload) {
				uni.hideLoading();
			}

			if (e.status == 200||e.status == 1||e.code==1) {
				callback && callback(e);
			} else {
				console.log(e);
				uni.showModal({
					title: '提示',
					content: e.msg,
					showCancel: false,
					success: function(res) {
						if (iserrorback) {
							uni.navigateBack({
							})
						}

						// if (res.confirm) {
						// 	console.log('用户点击确定');
						// } else if (res.cancel) {
						// 	console.log('用户点击取消');
						// }
					}
				});
				uni.hideLoading();



			}
		}).Catch(function(a) {

			console.error("请求异常请刷新重试");
		}).Post();
	}

	return SocketUser;

}());


export default {
	SocketUser: SocketUser
};
